"""
-*- coding:utf-8 -*-
__project_ = PyCharm Community Edition
__file_name__ = SEday4
__author__ = 'WangYulin'
__time__ = 2020/12/30 16:17
__product_name = PyCharm Community Edition 
# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By


def get_element(driver, *loc):
    e = driver.find_element(*loc)   #用一个find_element可以实现所有的定位
    return e


if __name__ == '__main__':
    driver = webdriver.Chrome()
    driver.get("http://www.baidu.com")
    driver.maximize_window()
    sleep(2)

    loc = (By.ID,'kw')

    get_element(driver, *loc).send_keys("今天星期三")
    get_element(driver, By.ID, 'su').click()    #不定长参数，可以传多个进来
    get_element(driver, By.NAME, 'wd').clear()
    sleep(1)
    get_element(driver, By.CSS_SELECTOR, '.s_ipt').send_keys('明天星期四')
    sleep(2)
    driver.quit()
